define('wg.itemV2',
function(require, exports, module) {
	var $ = require('mobile.zepto'),
	url = require('url'),
	loopSrcoll = require('wg.loopSrcoll'),
	ls = require('loadscript'),
	propSelector = require('wg.propSelector');
	var ItemDet = function() {
		var opt = {
			isAndroid23: false,
			isWX: true,
			itemType: 'normal',
			juBanner: '',
			isUseSticky: false,
			bid: '',
			itemId: '',
			status: '2',
			loopImg: [],
			skuChoose: {},
			cmdtySku: null,
			sliderProtal: null,
			sliderDetail: null,
			pageWidth: 0,
			lockScrollH: 0,
			skuViewH: 0,
			detBuyBtnH: 0,
			dw: 0,
			isAddCart: false,
			quckIcoShow: false,
			detPCshow: false,
			blackCoverShow: false,
			buyBtmFloatShow: false,
			detTabFloatShow: false,
			isLoadDet: [1, 0, 1, 0],
			isDetPCStr: '',
			detTabH: 0,
			detLowH: 0,
			detIndex: 1,
			lastST: 0,
			commStr: '',
			evalHold: false,
			evalTotal: 0,
			evalPage: 1,
			evalPageCur: 1,
			itilList: [],
			buyNum: 1
		};
		$.extend(this, opt);
	};
	ItemDet.prototype.init = function() {
		var os = $.os;
		this.isAndroid23 = os && os.android && (os.version.indexOf('2.3') != -1);
		this.isUseSticky = this.supportSticky();
		if (this.isAndroid23) $('body').addClass('android_23_fix');
		this.bid = url.getUrlParam('bid');
		this.itemId = url.getUrlParam('ic');
//		if (!this.itemId) {
//			alert('链接地址错误，请检查。');
//			return;
//		}
		this.dw = document.documentElement.clientWidth;
		this.detLowH = $(window).height() - $('#detailTab').height() + 20;
		this.pageWidth = $(window).width();
		this.checkBrowser();
		this.setDet();
		var obj = this;
		setInterval(function() {
			if (obj.itilList.length) {
				$itilReport({
					bid: "8",
					mid: '03',
					res: obj.itilList
				});
				obj.itilList = [];
			}
		},
		3000);
	};
	ItemDet.prototype.checkBrowser = function() {
		this.isWX = !!url.getUrlParam('pty') || window.WeixinJSBridge;
		if (!this.isWX) {
			var ua = navigator.userAgent.toLowerCase();
			this.isWX = ua.match(/micromessenger/) ? true: false;
		}
		var scence = url.getUrlParam('scence');
		scence = scence ? scence: 101;
		var tp = {
			101 : 'normal',
			102 : 'weishop',
			103 : 'brand',
			104 : "ju",
			105 : "shouq",
			188 : "test"
		} [scence];
		this.itemType = tp || this.itemType;
		if (this.itemType == 'weishop') {
			$('#severTitle1').show();
			$('#shopUrl').parent().hide();
			$('#shopUrl').html('进入微店<i class="arr_r_s"></i>');
		} else if (this.itemType == 'brand') {} else if (this.itemType == 'ju') {
			this.juBanner = window._banner;
		} else {
			$('#severTitle2').show();
		}
	};
	ItemDet.prototype.getCPCinfo = function() {
		var actid = url.getUrlParam('actid');
	};
	ItemDet.prototype.setDet = function() {
		var obj = this;
		var setNoteInfo = function(cmdtyInfo, json) {
			if (cmdtyInfo.C_BuyLimit > 0) $('#buyLimit').html('限购' + cmdtyInfo.C_BuyLimit + '件');
			$('#shopName').html(json.user.User_NickName);
			$('#shopUrl').attr('href', 'http://shop.wanggou.com/' + cmdtyInfo.C_Uin + '?PTAG=40042.1.15');
		};
		function reportPV(objMsg) {
			if (!window.ECC) {
				setTimeout(function() {
					//report(objMsg);
				},
				100);
			} else {
				window.ECC.cloud.report.pv(objMsg);
			}
		}
		var setProtalImg = function(arr) {
			var html = [],
			tab = [],
			reg = new RegExp(/\s+/g);
			if (obj.itemType == 'ju' && obj.juBanner) {
				arr = [obj.juBanner].concat(arr);
			}
			
			for (var i = 0; i < arr.length; i++) {
				arr[i] = arr[i].replace(reg, '');
				obj.loopImg.push(arr[i]);
				tab.push('<li></li>');
			}
			$('#loopImgBar').html(tab.join(''));
			$('#loopImgUl').css({
				left: '0px'
			});
			obj.sliderProtal = loopSrcoll.init({
				tp: 'img',
				loadImg: true,
				moveDom: $('#loopImgUl'),
				moveChild: $('#loopImgUl li'),
				tab: $('#loopImgBar li'),
				loopScroll: true,
				lockScrY: true,
				viewDom: obj.itemType == 'ju' ? $('#loopImgUl').parent() : null,
				index: 1,
				fun: function(index) {}
			});
			if (arr.length) {
				window.shareConfig.img_url = arr[0].replace('400x400', '120x120');
				if ($('#cartMover img').length) $('#cartMover img').attr('src', arr[0]);
			}
		};
		var setDetParam = function(arr, d) {
			var html = [];
			for (var i = 0; i < arr.length; i++) {
				html.push('<tr><td>' + arr[i].C_Attribute_Option_AttrName + '</td><td>' + arr[i].C_Attribute_Option_Text + '</td></tr>');
			}
			if (d.C_StartTimeString) html.push('<tr><td>开始时间</td><td>' + d.C_StartTimeString + '</td></tr>');
			if (d.C_EndTimeString) html.push('<tr><td>结束时间</td><td>' + d.C_EndTimeString + '</td></tr>');
			if (d.C_Baoxiu) html.push('<tr><td>保修</td><td>' + d.C_Baoxiu + '</td></tr>');
			if (d.C_Fapiao) html.push('<tr><td>发票</td><td>' + d.C_Fapiao + '</td></tr>');
			$('#detParam').html(html.join(''));
			if (obj.itemType != 'ju' && obj.itemType != 'brand') {
				obj.sliderDetail = loopSrcoll.init({
					moveDom: $('#detailCont'),
					moveChild: $('#detailCont > div'),
					tab: $('#detailTab span'),
					index: 1,
					lockScrY: true,
					min: obj.pageWidth,
					step: obj.pageWidth,
					fun: function(index) {
						obj.showDetTab(index);
					}
				});
			} else {
				obj.detIndex = 1;
				obj.loadCommDet();
			}
		};
		var itemback = function(json) {
			cmdtyInfo = json.commodity;
			if (!cmdtyInfo || json.errCode != '0') obj.itilList.push('0:0');
			if (json.desc) {
				obj.commStr = json.desc.C_MobileDescFileName;
				obj.commStrPC = json.desc.C_DescFileName;
			}
			obj.buyLimit = cmdtyInfo.C_BuyLimit * 1;
			obj.status = cmdtyInfo.C_State;
			setNoteInfo(cmdtyInfo, json);
			obj.setStatus(cmdtyInfo);
			setProtalImg(cmdtyInfo.C_MainLogo);
			obj.bindEvent();
			obj.setSeverIco(cmdtyInfo.C_PropertyBit, cmdtyInfo.C_Promotional);
			obj.setDsr(json.user.User_IntegratedDsrPoint);
			setDetParam(json.classattributes, cmdtyInfo);
//			if (cmdtyInfo.stocklist && cmdtyInfo.stocklist.length) {
//				obj.cmdtySku = propSelector.init({
//					cmdtyId: obj.itemId,
//					stocklist: cmdtyInfo.stocklist,
//					renderHtml: false,
//					manualSelect: true,
//					stockData: cmdtyInfo.StockList_StockString,
//					onSkuEmpty: function() {},
//					onSelected: function(propData) {
//						obj.skuChoose = propData;
//						obj.setTotalPrice();
//						obj.setBuyNum(obj.buyNum);
//						if (propData.stockCount) $('#skuStock').html('库存' + propData.stockCount + '件');
//						if (propData.img) obj.showSkuImg(propData.img);
//					}
//				});
//				obj.skuChoose = obj.cmdtySku.getSelectedProp();
//				if (obj.skuChoose.stockCount) $('#skuStock').html('库存' + obj.skuChoose.stockCount + '件');
//				var skuKey = [];
//				for (k in obj.skuChoose.propMap) skuKey.push(k);
//				$('#skuTitle').html(skuKey.join('/'));
//			} else {
//				$('#skuEnter').hide();
//				$('#skuCont').addClass('sku_no_sku');
//				obj.skuChoose = {
//					prop: [],
//					stockCount: 999999,
//					skuid: cmdtyInfo.StockList_StockSkuId
//				};
//			}
			obj.detTabH = $('#detailBaseLine').offset().top;
			obj.detBuyBtnH = $('#buyBtn').offset().top + $('#buyBtn').height();
			setTimeout(function() {
				obj.loadEvalNum();
			},
			1000);
			window.shareConfig.title = cmdtyInfo.C_Title;
			if (obj.itemType == 'ju') {
				window.shareConfig.desc = '聚惠价：' + $('#priceSale').attr('price') + '。聚优品，聚生活，9点抢购，全场包邮。';
			} else if (obj.itemType == 'brand') {
				window.shareConfig.desc = '售价：' + $('#priceSale').attr('price') + '。精选品牌每日更新，9点开抢限时抢购。';
			} else {
				window.shareConfig.desc = '售价：' + $('#priceSale').attr('price') + '。微信专享，正品保证。';
			}
			var ua = navigator.userAgent.toLowerCase(),
			client = (/qq\/([\d\.]+)*/).test(ua) ? 2001 : 4001;
			var objMsg = {
				p: "paipai.com",
				"client": client,
				weixin: 1,
				sku: json.commodity.C_ID,
				shop: json.commodity.C_Uin,
				leaf: json.commodity.C_ClassID
			};
			reportPV(objMsg);
		};
		itemback(window._itemInfo);
		obj.itilList.push('0:1');
	};
	ItemDet.prototype.setStatus = function(cmdtyInfo) {
		if (this.status == '2') return;
		var obj = this;
		if (this.status == '64') {
			var limit = Date.parse(cmdtyInfo.C_StartTimeString.replace(/-/g, '/') + ':00') - cmdtyInfo.C_ServerTime * 1000;
			if (limit) setTimeout(function() {
				$('#statusNotice').hide();
				$('#buyBtn, #buyBtn2').removeClass('btn_buy_disabled');
				obj.status = '2';
			},
			limit);
		}
		$('#statusNotice').show();
		$('#buyBtn, #buyBtn2').addClass('btn_buy_disabled');
	};
	ItemDet.prototype.setSeverIco = function(str, cuxiao) {
		var cxicon = [];
		if (str.charAt(255 - 25) == "1") cxicon.push('<span><i class="i_z"></i><b>假一赔三</b></span>');
		if (str.charAt(255 - 18) == "1") cxicon.push('<span><i class="i_x"></i><b>先行赔付</b></span>');
		if (str.charAt(255 - 19) == "1") cxicon.push('<span><i class="i_q"></i><b>7天包退</b></span>');
		if (str.charAt(255 - 67) == "1") cxicon.push('<span><i class="i_b"></i><b>免邮包退</b></span>');
		if (str.charAt(255 - 68) == "1") cxicon.push('<span><i class="i_k"></i><b>快速发货</b></span>');
		$('#severIco, #severIco2').html(cxicon.join(''));
	};
	ItemDet.prototype.setDsr = function(dsr) {
		$('#dsrP').html('<span style="width: ' + parseInt(dsr * 100 / 5) + '%"></span>');
		$('#dsrNum').html(dsr);
	};
	ItemDet.prototype.showSkuImg = function(url) {
		var imgs = $('#loopImgUl img'),
		url = url.replace('80x80', '400x400').replace(/\s+/g, '');
		$('#loopImgUl img')[imgs.length > 1 ? 2 : 0].src = url;
		this.loopImg[imgs.length > 1 ? 1 : 0] = url;
		this.sliderProtal.stepMove(2);
		return;
	};
	ItemDet.prototype.loadEvalNum = function() {
		ls.loadScript('http://shanghu.wanggou.com/tws/eval/creditinfo/CmdyEvalStat?sCmdyId=' + this.itemId + '&nSrc=1');
		window._commodityEvalStat_callback = function(json) {
			var total = json.nCommodityGoodNum * 1 + json.nCommodityNormalNum * 1 + json.nCommodityBadNum * 1;
			$('#evalNum').html(total);
		};
	};
	ItemDet.prototype.loadEval = function() {
		this.isLoadDet[3] = 1;
		var obj = this;
		if (this.evalHold || this.evalPageCur > this.evalPage) {
			return;
		}
		$('#eveaLoading').html('<img class="detail_loading" src="http://static.paipaiimg.com/wx/img/common/loading.gif">');
		this.evalHold = true;
		var evalTimer = setTimeout(function() {
			obj.itilList.push('2:0');
		},
		7000);
		ls.loadScript('http://shanghu.wanggou.com/tws/eval/creditinfo/NewCmdyEval?sCmdyId=' + this.itemId + '&nCurPage=' + this.evalPageCur + '&nTotal=' + this.evalTotal + '&nFilterType=1&nSrc=1');
		window.commodityRateListCallBack = function(json, no) {
			clearTimeout(evalTimer);
			obj.itilList.push(json.nErrNo != 0 ? '2:0': '2:1');
			$('#eveaLoading').html('');
			var data = json.evalList,
			html = [],
			tpl = document.getElementById('evalTpl').text;
			for (var i = 0; data[i] && i < data.length; i++) {
				data[i].data = data[i].peerTime.slice(0, 10);
				html.push($jsonToTpl(data[i], tpl));
			};
			$('#evalDet').append(html.length ? html.join('') : '暂无评价，欢迎您购买之后留下您的宝贵评价：）<br><br><br><br><br><br><br><br><br><br><br><br>');
			obj.evalPageCur++;
			obj.evalHold = false;
			obj.evalPage = json.nTotalPage;
			obj.evalTotal = json.nTotalRecord;
			obj.showDetTab(obj.detIndex);
		};
	};
	ItemDet.prototype.loadCommDet = function() {
		this.isLoadDet[1] = 1;
		var obj = this;
		$('#commDesc').html('<img class="detail_loading" src="http://static.paipaiimg.com/wx/img/common/loading.gif">');
		ls.loadScript('http://bases.wanggou.com/itemweb/desc?callback=commDetCallBack&filename=' + this.commStr);
		window.commDetCallBack = function(json) {
			var str = '该商品没有商品详情<br>';
			if (json.retCode != 0) {
				obj.loadCommDetPC('mobile');
				$('#pcItemLink').hide();
				return;
			} else {
				str = obj.tavlHTML(json.C_MobileDesc);
			}
			$('#commDesc').html(str);
			obj.showDetTab(obj.detIndex);
			obj.initLoadImg('detMobile');
		};
	};
	ItemDet.prototype.loadCommDetPC = function(showArea) {
		var obj = this;
		if (this.isDetPCStr) {
			if (showArea == "mobile") {
				$('#commDesc').html(this.isDetPCStr == 'none' ? '拉取商品详情失败，请稍候再试。': '(显示电脑端商品详细内容，会消耗您较多流量)<br>' + this.isDetPCStr);
				obj.initLoadImg('detMobile');
			} else {
				$('#detailPC').html(this.isDetPCStr);
				setTimeout(function() {
					obj.initLoadImg('detPC');
				},
				300);
			}
			return;
		}
		if (showArea != "mobile") $('#detailPC').html('<img class="detail_loading" src="http://static.paipaiimg.com/wx/img/common/loading.gif">');
		ls.loadScript('http://bases.wanggou.com/itemweb/desc?callback=commDetPCCallBack&filename=' + this.commStrPC);
		var commTimer = setTimeout(function() {
			obj.itilList.push('1:0');
		},
		7000);
		window.commDetPCCallBack = function(json) {
			clearTimeout(commTimer);
			$('#detailPC').html('');
			obj.isDetPCStr = 'none';
			if (json.retCode == 0) {
				obj.isDetPCStr = obj.tavlHTML(json.C_MobileDesc);
				obj.itilList.push('1:1');
			} else {
				obj.itilList.push('1:0');
			}
			obj.loadCommDetPC(showArea);
		};
	};
	ItemDet.prototype.tavlHTML = function(str) {
		var imgReg = /<img([^>]+)src="([^"]+)"([^>]+)/ig,
		emptyImg = 'http://static.paipaiimg.com/qqbuy/img/transparent.png',
		linkReg1 = /href="([^"]+)"/ig,
		linkReg2 = /href='([^']+)'/ig,
		linkReg3 = /height="0px"/ig;
		return str = str.replace(imgReg, '<img$1init_src="$2" src="' + emptyImg + '"$3').replace(linkReg1, '').replace(linkReg2, '').replace(linkReg3, 'style="display:none"');
	};
	ItemDet.prototype.getBuyLink = function() {
		if (this.status != '2') return '';
		var propData = this.skuChoose,
		skuPro = encodeURI(propData.prop.join('|'));
		var url = 'http://m.buy.qq.com/p/cart/order/s_confirm.shtml?bid=' + this.bid + '&isCanEdit=1&EncryptInfo=&Token=&scene=0&commlist=' + [this.itemId, skuPro, this.buyNum, propData.skuid].join(',');
		return url;
	};
	ItemDet.prototype.addShopingCart = function(em) {
		var obj = this,
		propData = this.skuChoose,
		skuPro = encodeURI(propData.prop.join('|'));
		ls.loadScript('http://bases.wanggou.com/mcart/addcmdy?commlist=' + [this.itemId, skuPro, this.buyNum, propData.skuid].join(',') + '&type=0&callback=cartBack&t=' + Math.random());
		window.cartBack = function(json) {
			if (json.errId == '1' || json.errId == '0') {
				var cart = $('#cartMover'),
				icoPos = $(em).position();
				cart.show();
				cart.css({
					top: icoPos.top,
					left: icoPos.left,
					visibility: "visible",
					"-webkit-transform": "translate(0px,0px) scale(1)",
					"-webkit-transition": "0"
				});
				cart.css({
					"-webkit-transform": "translate(" + ($(window).width() - icoPos.left - 60) + "px," + ($(window).scrollTop() + $(window).height() - icoPos.top - 55) + "px) scale(0.2)",
					"-webkit-transition": "all 1000ms ease"
				});
				setTimeout(function() {
					obj.showSkuNotice('添加购物车成功');
					cart.hide();
					$('#addCartNum').html('+' + obj.buyNum);
					$('#addCartNum').addClass('an_add_cart');
					setTimeout(function() {
						$('#addCartNum').removeClass('an_add_cart');
					},
					500);
				},
				600);
				obj.isAddCart = true;
			} else if (json.errId == '2') {
				obj.showSkuNotice('购物车中的商品数量太多,请先移除部分商品再添加');
			} else if (json.errId == '4') {
				obj.showSkuNotice($('#skuTitle').html());
			} else if (json.errId == '13') {
				location.href = 'http://party.wanggou.com/tws64/m/h5v1/cpLogin?rurl=' + encodeURIComponent(location.href);
			} else {
				obj.showSkuNotice(json.errMsg);
			}
		};
	};
	ItemDet.prototype.setTotalPrice = function() {
		if (this.skuChoose.price) {
			$('#priceSale').html('&yen;' + (this.skuChoose.price * this.buyNum).toFixed(2));
		} else {
			$('#priceSale').html($('#priceSale').attr('price'));
		}
	};
	ItemDet.prototype.setBuyNum = function(num) {
		var maxNum = this.buyLimit ? Math.min(this.skuChoose.stockCount, this.buyLimit) : this.skuChoose.stockCount;
		num = Math.max(1, num);
		num = Math.min(maxNum, num);
		this.buyNum = num;
		$('#buyNum').val(num);
		this.setTotalPrice();
		num == 1 ? $('#minus').addClass('minus_disabled') : $('#minus').removeClass('minus_disabled');
		maxNum <= num ? $('#plus').addClass('plus_disabled') : $('#plus').removeClass('plus_disabled');
	};
	ItemDet.prototype.showDetTab = function(index) {
		var isChange = this.detIndex != index;
		var st = $(window).scrollTop();
		this.detTabH = $('#detailBaseLine').offset().top;
		this.detIndex = index;
		if (!this.isLoadDet[index]) {
			if (index == 1) this.loadCommDet();
			if (index == 3) this.loadEval();
			return;
		}
		if (st > this.detTabH && isChange) {
			window.scrollTo(0, this.detTabH);
		}
		this.setDetHeight();
	};
	ItemDet.prototype.setDetHeight = function() {
		if (this.itemType == 'ju' || this.itemType == 'brand') return;
		var h = $("#detail" + this.detIndex).height();
		$("#detail").css('height', Math.max(h, this.detLowH));
	};
	ItemDet.prototype.supportSticky = function() {
		var t, n = '-webkit-sticky',
		e = document.createElement("i");
		e.style.position = n;
		t = e.style.position;
		e = null;
		return t === n;
	};
	ItemDet.prototype.initLoadImg = function(tp) {
		var data = {
			cache: []
		},
		img = tp == 'detPC' ? $("#detailPC img") : $("#detail1 img");
		img.each(function(i) {
			var dom = $(this);
			data.cache.push({
				url: dom.attr('init_src'),
				dom: dom
			});
		});
		data.num = data.cache.length;
		data.viewHeight = $(window).height();
		data.scrollOffsetH = 100;
		if (tp == 'detPC') {
			data.scrollOffsetH = 500;
			window._imagePC_data = data;
		} else {
			window._images_data = data;
		}
		this.loadImg(tp);
	};
	ItemDet.prototype.loadImg = function(tp) {
		if (tp == 'detPC') {
			var scrollHeight = $('#detailPC').scrollTop(),
			d = window._imagePC_data;
		} else {
			var scrollHeight = $(window).scrollTop(),
			d = window._images_data;
		}
		if (d.num == 0) {
			return;
		}
		visibleHeight = d.viewHeight + scrollHeight + d.scrollOffsetH;
		$.each(d.cache,
		function(i, data) {
			var em = data.dom,
			imgH = tp == 'detPC' ? em.position().top: em.offset().top;
			if (visibleHeight > imgH && !em.attr("loaded")) {
				em.attr("src", data.url);
				em.removeAttr('init_src');
				em.attr("loaded", d.num + 1);
				d.num--;
			}
		});
	};
	ItemDet.prototype.scroll = function() {
		if (this.detPCshow || this.blackCoverShow) {
			if (this.detPCshow) this.loadImg('detPC');
			window.scrollTo(0, this.lockScrollH);
			return;
		}
		var obj = this,
		st = $(window).scrollTop();
		if (!this.isUseSticky) {
			this.detTabH = $('#detailBaseLine').offset().top;
			if (st > this.detTabH) {
				if (!this.detTabFloatShow) $('#detailTab').addClass('mod_tab_fixed');
				this.detTabFloatShow = true;
			} else {
				if (this.detTabFloatShow) $('#detailTab').removeClass('mod_tab_fixed');
				this.detTabFloatShow = false;
			}
		}
		if (st > this.detBuyBtnH) {
			if (!this.buyBtmFloatShow) {
				$('#buyAreaBtm').addClass('layer_show');
			}
			this.buyBtmFloatShow = true;
		} else {
			if (this.buyBtmFloatShow) {
				$('#buyAreaBtm').removeClass('layer_show');
			}
			this.buyBtmFloatShow = false;
		}
		this.setDetHeight();
		if (this.detIndex == 1) {
			//this.loadImg('detMobile');
		}
		if (this.itemType == 'ju' || this.itemType == 'brand') {
			if (st >= ($(document).height() - $(window).height() - 50)) {
				this.loadEval();
			}
		} else if (this.detIndex == 3) {
			if (st >= ($(document).height() - $(window).height())) {
				this.loadEval();
			}
		}
		if (this.quckIcoShow) {
			$('#quckFloat').hide();
			$('#quckIco1, #quckIco2').removeClass('avatar_wrap_on');
			this.quckIcoShow = false;
		}
	};
	ItemDet.prototype.hideDetPC = function() {
		if (this.itemType == 'ju' || this.itemType == 'brand') $('#topBar').show();
		$('#detailPCArea').removeClass('layer_show');
		setTimeout(function() {
			$('#detailPC').html('');
		},
		300);
		this.detPCshow = false;
	};
	ItemDet.prototype.checkSku = function() {
		var propData = this.skuChoose,
		emptyProp = [];
		for (var key in propData.propMap) {
			if (!propData.propMap[key]) {
				emptyProp.push("“" + key + "”");
			}
		}
		if (emptyProp.length > 0) {
			this.showSku(emptyProp.join('/'));
			return false;
		}
		return true;
	};
	ItemDet.prototype.showSku = function(str) {
		document.getElementById('skuCont').scrollIntoView(true);
		this.showSkuNotice('请选择' + str);
	};
	ItemDet.prototype.showSkuNotice = function(str) {
		if (!str) return;
		$('#skuTitle2').html(str);
		$('#skuNotice').show();
		$('#skuNotice').css('margin-left', '-' + ($('#skuNotice').width()) / 2 + 'px');
		setTimeout(function() {
			$('#skuNotice').hide();
		},
		2000);
	};
	ItemDet.prototype.resizeProtal = function(showBlack) {
		if (showBlack) {
			$('#loopImgDiv').hasClass('mod_slider_viewer') ? $('#loopImgDiv').removeClass('mod_slider_viewer') : $('#loopImgDiv').addClass('mod_slider_viewer');
		}
		if (this.itemType == 'ju') {
			var w = Math.min(this.pageWidth, 475);
			$('#loopImgUl li').width(w);
		}
		this.sliderProtal.resize($('#loopImgUl li').eq(0).width());
	};
	ItemDet.prototype.bindEvent = function() {
		$(window).on("scroll", $.proxy(this.scroll, this));
		var obj = this;
		var hideBlackCover = function() {
			$('#blackCover').hide();
			obj.blackCoverShow = false;
			if ($('#loopImgDiv').hasClass('mod_slider_viewer')) {
				obj.resizeProtal(true);
			} else {
				$('#imageViewer').hide();
			}
			$('#topBar').show();
		};
		var showSingeImg = function(src) {
			obj.lockScrollH = $(window).scrollTop();
			obj.blackCoverShow = true;
			$('#blackCover').show();
			$('#imageViewer').show();
			$('#fullImg').attr('src', src);
			$('#topBar').hide();
		};
		$('#loopImgUl').on('click',
		function(e) {
			if (window.WeixinJSBridge) {
				WeixinJSBridge.invoke('imagePreview', {
					'current': obj.loopImg[obj.sliderProtal.index - 1],
					'urls': obj.loopImg
				});
				return;
			}
			$('#topBar').hide();
			if (obj.loopImg.length == 1) {
				showSingeImg(obj.loopImg[0]);
				return;
			}
			if (!obj.loopImg.length) return;
			if ($('#loopImgDiv').hasClass('mod_slider_viewer')) {
				hideBlackCover();
			} else {
				obj.lockScrollH = $(window).scrollTop();
				obj.blackCoverShow = true;
				$('#blackCover').show();
				obj.resizeProtal(true);
			}
		});
		$('#commDesc').on('click',
		function(e) {
			var target = e.srcElement || e.target;
			if (target.nodeName == 'IMG') {
				if (window.WeixinJSBridge) {
					WeixinJSBridge.invoke('imagePreview', {
						'current': target.src,
						'urls': [target.src]
					});
				} else {
					showSingeImg(target.src);
				}
			}
		});
		$('body').on('touchend',
		function(e) {
			var target = e.srcElement || e.target,
			em = target,
			i = 1;
			while (!em.id && i <= 3) {
				em = em.parentNode;
				i++;
			}
			if (!em.id) return;
			switch (em.id) {
			case 'imageViewer':
			case 'fullImg':
				hideBlackCover();
				e.preventDefault();
				break;
			case 'blackCover':
				hideBlackCover();
				e.preventDefault();
				break;
				break;
			case 'detailClosePC':
				obj.hideDetPC();
				e.preventDefault();
				break;
			}
		});
		$('body').on('tap',
		function(e) {
			var target = e.srcElement || e.target,
			em = target,
			i = 1;
			while (!em.id && i <= 3) {
				em = em.parentNode;
				i++;
			}
			if (!em.id) return;
			switch (em.id) {
			case 'buyBtn':
			case 'buyBtn2':
				if (obj.status != '2') return false;
				if (!obj.checkSku()) return false;
				var url = obj.getBuyLink();
				obj.itilList.push('3:0');
				if (!url) return false;
				location.href = url;
				e.preventDefault();
				return false;
				break;
			case 'addCart':
			case 'addCart2':
				if (obj.isAddCart) {
					if (alert('已经添加购物车，是否去购物车查看？',1)) {
						window.location.href = 'http://mm.wanggou.com/item/wg_shopcart.shtml';
					}
					return false;
				}
				if (!obj.checkSku()) return false;
				obj.addShopingCart(em);
				break;
			case 'quckIco1':
			case 'quckIco2':
				if (obj.itemType == 'weishop' || obj.itemType == 'ju' || obj.itemType == 'brand') {
					$('#persLink').click();
					return;
				}
				if (obj.quckIcoShow) {
					$('#quckFloat').hide();
					$('#quckIco1, #quckIco2').removeClass('avatar_wrap_on');
				} else {
					$('#quckFloat').show();
					$('#quckIco1, #quckIco2').addClass('avatar_wrap_on');
				}
				obj.quckIcoShow = !obj.quckIcoShow;
				break;
			case 'plus':
			case 'minus':
				if (em.className.indexOf('disabled') != -1) return;
				var num = em.id == 'plus' ? obj.buyNum + 1 : obj.buyNum - 1;
				obj.setBuyNum(num);
				e.preventDefault();
				break;
			case 'pcItemLink':
				obj.lockScrollH = $(window).scrollTop();
				obj.loadCommDetPC();
				if (obj.itemType == 'ju' || obj.itemType == 'brand') $('#topBar').hide();
				$('#detailPCArea').addClass('layer_show');
				$('#detailPC').css('height', $(window).height() - 45);
				obj.detPCshow = true;
				break;
			case 'severArea':
			case 'severIco':
			case 'severTitle1':
			case 'severTitle2':
				$('#severArea').hasClass('discount_wrap_on') ? $('#severArea').removeClass('discount_wrap_on') : $('#severArea').addClass('discount_wrap_on');
				break;
			case 'topDetTab':
				var no = $(target).attr('no');
				if (!no) return;
				if ($(target).hasClass('on')) return;
				$('#topDetTab a').removeClass('on');
				$(target).addClass('on');
				window.scrollTo(0, 0);
				if (no == 1) {
					$('#page_goods').show();
					$('#page_comment').hide();
					obj.detIndex = 1;
				} else {
					$('#page_goods').hide();
					$('#page_comment').show();
					obj.detIndex = 3;
					obj.loadEval();
				}
				break;
			default:
				break;
			}
		});
		$('#buyNum').on('input',
		function() {
			if (this.value) obj.setBuyNum(this.value);
		});
		$('#buyNum').on('focus',
		function() {
			$('#quckIcoArea').hide();
			$('#buyAreaBtm').hide();
		});
		$('#buyNum').on('blur',
		function() {
			$('#quckIcoArea').show();
			$('#buyAreaBtm').show();
			obj.setBuyNum(this.value);
		});
		window.onresize = function() {
			if (obj.pageWidth == $(window).width()) return;
			obj.pageWidth = $(window).width();
			obj.resizeProtal();
			obj.sliderDetail && obj.sliderDetail.resize(obj.pageWidth);
		};
	};
	function $jsonToTpl(json, tpl) {
		return tpl.replace(/{#(\w+)#}/g,
		function(a, b) {
			return json[b] || "";
		});
	}
	function $itilReport(option) {
		var opt = {
			bid: "1",
			mid: "01",
			res: [],
			onBeforeReport: null,
			delay: 5000
		};
		for (var k in option) {
			opt[k] = option[k];
		}
		if (opt.res.length > 0) {
			window.reportWebInfo = function(json) {};
			window.setTimeout(function() {
				opt.onBeforeReport && opt.onBeforeReport(opt);
				var pstr = opt.bid + opt.mid + "-" + opt.res.join("|");
				var url = "http://focus.paipai.com/webreport/ReportWebInfo?report=" + pstr + "&t=" + new Date() / 1000;
				ls.loadScript(url);
			},
			opt.delay);
		}
	}
	exports.init = function() {
		var item = new ItemDet();
		item.init();
		window._itemDeatail = item;
	};
});
/*  |xGv00|a382f270b763e1307a1efb90dbc821c4 */
